<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
    <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
    <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
    <!--<script src="http://{$Think.config.google_map_url}" async="async"></script>-->
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->

</head>
<style>
    .layui-upload-img{
        width: 100px;!important;
    }
    .addclassify{
        display: inline-block;
        width: 40px;
        height: 40px;
        border: 1px solid #666;
        line-height: 40px;
        border-radius: 40px;
        text-align: center;
        cursor: pointer;
    }
</style><style>
    .list-group-item{
        margin: 5px 30px 5px 0;
        color: #212529;
        display: inline-block;
    }
    .list-group-item>i{
        color:red;
    }
</style>
<body>
<div style="margin-top: 20px;">
</div>

<form class="layui-form" id="admin">

    <div class="layui-tab layui-tab-card" style="box-shadow:none">
        <ul class="layui-tab-title">
            <li class="layui-this">基础信息</li>
            <li>视频相册</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">

                {notempty name="$goods"}
                <input type="hidden" name="goods_id" value="{$goods.goods_id}">
                {/notempty}

                <div class="layui-form-item " id="shangpin">
                    <label class="layui-form-label">商品名称</label>
                    <div class="layui-input-inline" style="width: 500px">
                        <input name="goods_name"  value='{notempty name="$goods"}{$goods.goods_name}{/notempty}' placeholder="请输入商品名称" autocomplete="off" class="layui-input"  type="text">
                    </div>
                </div>
                <div class="layui-form-item " id="">
                    <label class="layui-form-label">商品英文名称</label>
                    <div class="layui-input-inline" style="width: 500px">
                        <input name="goods_englishname"  value='{notempty name="$goods"}{$goods.goods_englishname}{/notempty}' placeholder="请输入商品名称" autocomplete="off" class="layui-input"  type="text">
                    </div>
                </div>

                <div class="layui-form-item ">
                    <label class="layui-form-label">产品Code</label>
                    <div class="layui-input-inline" style="width: 200px">
                        <input name="goods_tcode"  value='{notempty name="$goods"}{$goods.goods_tcode}{/notempty}' readonly class="layui-input"  type="text">
                    </div>
                </div>

                <!--<div class="layui-form-item " id="merchantNetPrice">-->
                <!--<label class="layui-form-label">采购价格(美元)</label>-->
                <!--<div class="layui-input-inline" style="width: 500px">-->
                <!--<input name="merchantNetPrice"  value="{$goods.merchantNetPrice}" placeholder="请输入商品名称" autocomplete="off" class="layui-input"  type="text">-->
                <!--</div>-->
                <!--</div>-->

                <!--<div class="layui-form-item " id="price">-->
                <!--<label class="layui-form-label">价格(美元)</label>-->
                <!--<div class="layui-input-inline" style="width: 500px">-->
                <!--<input name="price"  value="{$goods.price}" placeholder="请输入商品名称" autocomplete="off" class="layui-input"  type="text">-->
                <!--</div>-->
                <!--</div>-->

                <div class="layui-form-item ">
                    <label class="layui-form-label">虚拟销量</label>
                    <div class="layui-input-inline" style="width: 200px">
                        <input value="{$goods.invented_sold|default=0}" name="invented_sold" autocomplete="off" class="layui-input"  type="text">
                    </div>
                </div>

                <div class="layui-form-item ">
                    <label class="layui-form-label">真实销量</label>
                    <div class="layui-input-inline" style="width: 200px">
                        <input value="{$goods.goodssales|default=0}" readonly autocomplete="off" class="layui-input"  type="text">
                    </div>
                </div>

                <div class="layui-form-item " >
                    <label class="layui-form-label">城市</label>
                    <div class="layui-input-inline" style="width: 450px">
                        <!--<input name="xp"  id="xp" value="" placeholder="请输入" autocomplete="off" list="list" class="layui-input"  type="text">-->
                        <select  lay-filter="city"   name="city_id"  lay-verify="required" lay-search>
                            {volist name="city" id="vo"}
                            <option value="{$vo.id}" {if $goods.city_id==$vo.destid OR $goods.city_id==$vo.id} selected{/if}>{$vo.name}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
                <input type="hidden"  id="city" value="{notempty name='$goods'}{$goods.city_id}{else}{notempty name='$city[0]["id"]'}{$city[0]['id']}{/notempty}{/notempty}">

                <div class="layui-form-item ">
                    <label class="layui-form-label">商城分类</label>
                    <div class="layui-input-inline" style="width: 450px">
                        <!--<input name="xp"  id="xp" value="" placeholder="请输入" autocomplete="off" list="list" class="layui-input"  type="text">-->
                        <select  lay-filter="classify"   name="classify_id"  lay-verify="required" lay-search>
                            {volist name="classify" id="vo"}
                            <option value="{$vo.classify_id}" {if $goods.classify_id==$vo.classify_id} selected{/if}>{$vo.classify_name}</option>
                            {/volist}
                        </select>
                    </div>
                </div>


                <div class="layui-form-item ">
                    <label class="layui-form-label">订单分类</label>
                    <div class="layui-input-inline" style="width: 450px">
                        <select name="orderType" lay-verify="required" lay-search>
                            <option value>请选择</option>
                            {volist name="orderType" id="vo"}
                            <option value="{$vo.type}" {if $goods.orderType==$vo.type} selected{/if}>{$vo.name}</option>
                            {/volist}
                        </select>
                    </div>
                </div>


                <input type="hidden"  id="classify" value="{notempty name='$goods'}{$goods.classify_id}{else}{notempty name="$classify[0]['classify_id']"}{$classify[0]['classify_id']}{/notempty}{/notempty}">


                <div class="layui-form-item " >
                    <label class="layui-form-label">标签</label>
                    <div class="layui-input-inline" style="width: 400px">
                        <select  id="trip"  lay-filter="addtrips"   lay-verify="required" lay-search>
                            {volist name="tag" id="vo"}
                            <option value="{$vo.tag_id}">{$vo.tag_name}</option>
                            {/volist}
                        </select>
                    </div>
                    <span id="addtrips" data-name="{notempty name='$tag[0]["tag_id"]'}{$tag[0]["tag_name"]}{/notempty}" data-id="{notempty name='$tag[0]["tag_id"]'}{$tag[0]["tag_id"]}{/notempty}" class="layui-btn layui-btn-danger layui-btn-sm" style="margin-top: 4px">添加</span>
                </div>



                <div class="layui-form-item">
                    <label class="layui-form-label">已选标签</label>
                    <div class="layui-input-inline" style="width: 500px" id="tripnames">
                        {volist name="tagdata" id="vo"}
                        <span class="layui-btn layui-btn-sm layui-btn-normal deltripspan" data-id="{$vo['tag_id']}" style="margin: 5px 10px">{$vo['tag_name']}<i class="layui-icon"></i></span>
                        {/volist}
                    </div>
                </div>

                <input name="tag_id" id="tripids" value="{notempty name="$goods"}{$goods.tag_id}{/notempty}"   type="hidden">



                <div class="layui-form-item ">
                    <label class="layui-form-label">商品标签</label>
                    <div class="layui-input-inline" style="width: 450px">
                        <select name="goodstag_id" lay-search>
                            <option value="0">暂不配置</option>
                            {volist name="goodstags" id="vo"}
                            <option value="{$vo.tag_id}" {if $goods.goodstag_id==$vo.tag_id} selected{/if}>{$vo.tag_name}</option>
                            {/volist}
                        </select>
                    </div>
                </div>


                <div class="layui-form-item " id="" >
                    <label class="layui-form-label">选择状态</label>
                    <div class="layui-input-inline">
                        <select name="goods_status"  lay-verify="required">
                            <option value="1" {if $goods.goods_status==1} selected{/if}>售卖中</option>
                            <option value="2" {if $goods.goods_status==2} selected{/if}>未售卖</option>
                            <option value="3" {if $goods.goods_status==3} selected{/if}>已售罄</option>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">上架时间</label>
                    <div class="layui-input-inline" style="width: 450px">
                        <div  class=" layui-col-xs5">
                            <input name="starttime"  value="{notempty name="$goods"}{$goods.starttime|date="Y-m-d",###}{/notempty}"  id="start_goodstime"  lay-verify="required" placeholder="请输入开始时间" autocomplete="off" class="layui-input" type="text">
                        </div>
                        <div class="layui-col-xs2" style="text-align: center; line-height: 38px">~</div>
                        <div  class=" layui-col-xs5">
                            <input name="endtime"  value="{notempty name="$goods"}{$goods.endtime|date="Y-m-d",###}{/notempty}"  id="end_goodstime"  lay-verify="required" placeholder="请输入结束时间" autocomplete="off" class="layui-input layui-col-xs5" type="text">
                        </div> </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">是否可退</label>
                    <div class="layui-input-inline">
                        {if $goods.merchantCancellable==1}
                        <input type="text" value="可退" class="layui-input" readonly>
                        {else}
                        <input type="text" value="不可退" class="layui-input" readonly>
                        {/if}
                    </div>
                </div>

                <div class="layui-form-item " hidden>
                    <label class="layui-form-label">商品录入方式</label>
                    <div class="layui-input-inline" style="width: 450px">
                        <!--<input name="xp"  id="xp" value="" placeholder="请输入" autocomplete="off" list="list" class="layui-input"  type="text">-->
                        <select  lay-filter="city" id="goods_source"  name="goods_source"  lay-verify="required" lay-search>
                            <option value="1" selected>手工录入</option>
                            <option value="2">第三方API</option>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item ">
                    <label class="layui-form-label">订单类型</label>
                    <div class="layui-input-inline" style="width: 450px">
                        <select  name="need_confirm"  lay-verify="required" disabled>
                            <option  value="2" {if $goods.need_confirm==2} selected{/if}>立即确认</option>
                            <option  value="1" {if $goods.need_confirm==1} selected{/if}>待供应商确认</option>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item " >
                    <label class="layui-form-label">预约问题</label>
                    <div class="layui-input-inline" style="width: 450px">
                        <!--<input name="xp"  id="xp" value="" placeholder="请输入" autocomplete="off" list="list" class="layui-input"  type="text">-->
                        <select  lay-filter="city" id="isquestion"  name="isquestion"  lay-verify="required" disabled>
                            <option value="2"  {if $goods.isquestion==2} selected{/if}>有</option>
                            <option value="1" {if $goods.isquestion==1} selected{/if}>没有</option>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item ">
                    <label class="layui-form-label">旅客信息类型</label>
                    <div class="layui-input-inline" style="width: 450px">
                        <select lay-verify="required" disabled>
                            <option value="1" {if $goods.alltravellermessage==1} selected{/if}>必须真实信息</option>
                            <option value="0" {if $goods.alltravellermessage==0} selected{/if}>允许拟设信息</option>
                        </select>
                    </div>
                </div>


                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                    <legend class="layui-inline">toB分类</legend>
                    <p class="layui-inline" style="margin-left: 20px;color:palevioletred">【已选详细分类】支持拖拽排序！优先使用靠前的分类进行显示</p>
                </fieldset>
                <!--顶级分类-->
                <!--<div class="layui-form-item" id="topCategory">-->
                    <!--<label class="layui-form-label">顶级分类</label>-->
                    <!--<div class="layui-input-inline" style="width: 400px">-->
                        <!--<select name="topCate" id="topCate" lay-filter="topCate" lay-search>-->
                            <!--<option value="">请选择顶级分类</option>-->
                            <!--{notempty name="$topCate"}-->
                            <!--{volist name="topCate" id="vo"}-->
                            <!--<option value="{$vo.id}" {notempty name="$standard.topCate"}{if $standard.topCate==$vo.id}selected{/if}{/notempty}>{$vo.name}</option>-->
                            <!--{/volist}-->
                            <!--{/notempty}-->
                        <!--</select>-->
                    <!--</div>-->
                <!--</div>-->
                <!--详细分类[多选]-->
                <div class="layui-form-item" id="firstCategory">
                    <label class="layui-form-label">详细分类<br>[多选]</label>
                    <div class="layui-input-inline" style="width: 400px">
                        <select name="categorytagid" id="categorytags" lay-filter="addCategoryTags" lay-search>
                            <option value="">请选择详细分类</option>
                            <!--初始化-->
                            {notempty name="$tags"}
                            {volist name="tags" id="cate"}
                            <option value="{$cate.tag_id}">{$cate.tag_name}</option>
                            {/volist}
                            {/notmepty}
                        </select>
                    </div>
                </div>
                <!--已选详细分类-->
                <div class="layui-form-item" >
                    <label class="layui-form-label">已选<br>详细分类</label>
                    <div class="layui-input-inline" style="width: 400px">
                        <blockquote class="layui-elem-quote elem-quote-div">
                            <div id="shared-lists" class="shared-lists">
                                <div class="boxcont" id="boxcont">
                                    <div id="sortTags" class="example2 schedule_div" style="padding:15px;">
                                        {notempty name="$tagsData"}
                                        {volist name="tagsData" id="tag"}
                                        <span class="list-group-item list-group-{$tag.tagid}" value="{$tag.tagid}" id="{$tag.tagid}">{$tag.tag_name}<i class="layui-icon">&#x1006;</i></span>
                                        {/volist}
                                        {/notempty}
                                    </div>
                                </div>
                            </div>
                        </blockquote>
                    </div>
                </div>
                <input type="hidden" name="subCates" value="{notempty name='$tagsData'}{$tagsData|array_column=###,'tagid'|implode=',',###}{/notempty}">
                <div class="layui-form-item">
                    <label class="layui-form-label">上架ToB</label>
                    <div class="layui-input-inline" style="width: 450px">
                        <input type="radio" name="show_toB" value="1" {if $standard.show_toB=='1'}checked=""{/if} title="是" >
                        <input type="radio" name="show_toB" value="0" {if $standard.show_toB=='0'}checked=""{/if} title="否" >
                    </div>
                </div>
                <fieldset class="layui-elem-field layui-field-title" style="margin-bottom: 30px;">

                </fieldset>


                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">内部备注</label>
                    <div class="layui-input-block" style="max-width:500px;">
                        <textarea placeholder="请输入内容" class="layui-textarea"  name="internal_remark">{notempty name='$goods.internal_remark'}{$goods.internal_remark}{/notempty}</textarea>
                    </div>
                </div>


                <div class="layui-form-item layui-form-text" style="position: relative ;z-index: 98">
                    <label class="layui-form-label">简介</label>
                    <div class="layui-input-block" style="max-width:500px;">
                        <textarea placeholder="请输入内容"  class="layui-textarea" id="jieshao" name="goods_introduce">{notempty name="$goods"}{$goods.goods_introduce}{/notempty}</textarea>
                    </div>
                </div>


                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">用时参考</label>
                    <div class="layui-input-block" style="max-width:500px;">
                        <textarea placeholder="请输入内容"  class="layui-textarea" id="yongshi" name="goods_usetime">{notempty name="$goods"}{$goods.goods_usetime}{/notempty}</textarea>
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">费用包含</label>
                    <div class="layui-input-block" style="max-width:500px;">
                        <textarea placeholder="请输入内容"  class="layui-textarea" id="baohan" name="price_include">{notempty name="$goods"}{$goods.price_include}{/notempty}</textarea>
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">费用不含</label>
                    <div class="layui-input-block" style="max-width:500px;">
                        <textarea placeholder="请输入内容"  class="layui-textarea" id="buhan" name="price_noinclude">{notempty name="$goods"}{$goods.price_noinclude}{/notempty}</textarea>
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">注意事项</label>
                    <div class="layui-input-block" style="max-width:500px;">
                        <textarea placeholder="请输入内容"  class="layui-textarea" id="zhuyi" name="goods_careful">{notempty name="$goods"}{$goods.goods_careful}{/notempty}</textarea>
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">退改规则</label>
                    <div class="layui-input-block" style="max-width:500px;">
                        <textarea placeholder="请输入内容"  class="layui-textarea" id="tuigai" name="goods_retreating">{notempty name="$goods"}{$goods.goods_retreating}{/notempty}</textarea>
                    </div>
                </div>

                <!--<div class="layui-form-item layui-form-text">-->
                <!--<label class="layui-form-label">英文介绍</label>-->
                <!--<div class="layui-input-block" style="max-width:500px;">-->
                <!--<textarea placeholder="请输入内容"  class="layui-textarea" id="jieshao2" name="goods_enintroduce"></textarea>-->
                <!--</div>-->
                <!--</div>-->

            </div>
            <div class="layui-tab-item">
                <div class="layui-form-item" style="margin:0 110px ">
                    <div class="layui-upload">
                        <button type="button" class="layui-btn" id="upload1">图片上传（格式：jpg,png,gif,jpeg）                                                                                      </button>
                        <button type="button" class="layui-btn layui-btn-warm" id="pullViatorImgs">拉取viator库图片                                                                                      </button>
                        <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                            预览图：
                            <div class="layui-upload-list" id="seeupload1">
                                {volist name="$goodsimage" id="vo"}
                                {notempty name='$vo'}
                                <span class="uploadimgbox"><img class="layui-upload-img" src="{$vo}" width="100px"><i class="layui-icon">&#x1006;</i></span>
                                {/notempty}
                                {/volist}
                            </div>
                        </blockquote>
                    </div>
                    <input id="upload-thumb1" type="hidden" name="goods_image" value="{notempty name='$goods'}{$goods.goods_image}{/notempty}">
                </div>
                <div class="layui-form-item" style="margin:0 110px ">
                    <div class="layui-upload">
                        <button type="button" class="layui-btn" id="test5"><i class="layui-icon"></i>上传视频</button>
                        <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                            视频预览：
                            <div class="layui-upload-list" id="seevideo">
                                {notempty name="$goods.goods_video"}
                                <video controls style="width: 400px">
                                    <source  src="{$goods.goods_video}">
                                </video>
                                {/notempty}
                            </div>
                        </blockquote>
                    </div>

                    <input id="upload-video" type="hidden" name="goods_video" value="{$goods.goods_video}">
                </div>

            </div>
        </div>


    </div>

    <!--<div class="layui-form-item">-->
    <!--<label class="layui-form-label">选择文件</label>-->
    <!--<div class="layui-input-inline">-->
    <!--<button type="button" class="layui-btn" id="uploadfile"><i class="layui-icon"></i><span id="uploadname">{if empty($menu['fileid'])||$menu['fileid']<1}上传文件{else}更改文件{/if}</span>（格式：PDF或者WORD）</button>-->
    <!--</div>-->
    <!--<input name="fileid" id="fileid" value="{notempty name='$menu'}{$menu.fileid}{/notempty}" placeholder="请输入" autocomplete="off" class="layui-input" type="hidden">-->
    <!--</div>-->

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="admin">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>

</form>

<script src="__PUBLIC__/layui/layui.js"></script>
<script src="__PUBLIC__/jquery/jquery.min.js"></script>
<script src="__PUBLIC__/drag/Sortable.js"></script>
<script>
    var message;
    layui.config({
        base: '__JS__/',
        version: '1.0.1'
    }).use(['app', 'message'], function() {
        var app = layui.app,
            $ = layui.jquery,
            layer = layui.layer;
        //将message设置为全局以便子页面调用
        message = layui.message;
        //主入口
        app.set({
            type: 'iframe'
        }).init();
    });
</script>
<!-- 配置文件 -->
<script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.all.js"></script>

<script>
    layui.use(['layer', 'form','laydate','element'], function() {
        var $ = layui.jquery,
            laydate= layui.laydate
            , element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块
        laydate.render({
            elem: '#start_goodstime' //指定元素
            ,trigger:'click'
        });
        laydate.render({
            elem: '#end_goodstime' //指定元素
            ,trigger:'click'
        });
    });



    //文件上传
    layui.use('upload', function(){
        var upload = layui.upload;
        //执行实例图片
        upload.render({
            elem: '#upload1'
            ,url: "{:url('common/upload')}"
            ,multiple: true
            ,accept:"images"
            ,size:"50000"
            ,done: function(res){
                //上传完毕回调
                layer.closeAll('loading');
                if(res.code == 2) {
                    $('#seeupload1').append('<span class="uploadimgbox"><img class="layui-upload-img" src="'+res.src+'"><i class="layui-icon">&#x1006;</i></span>');
                    $('#upload-thumb1').val($('#upload-thumb1').val()+","+res.src);
                } else {
                    layer.msg(res.msg);
                }
            }
            ,error: function(){
                //请求异常回调
                //演示失败状态，并实现重传
                layer.closeAll('loading');
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
            ,before:function () {
                layer.load(2);
            }
        });

        //执行实例视频
        upload.render({
            elem: '#test5'
            ,url: "{:url('common/upload')}"
            ,accept: 'video' //视频
            ,size:'65536'
            ,done: function(res){
                layer.closeAll('loading');
                if(res.code == 2) {
                    layer.msg("文件上传成功");
                    $("#seevideo").html('<video controls style="width: 400px">\n' +
                        '<source  src="'+res.src+'">\n' +
                        '</video>');
                    $("#upload-video").val(res.src);
                } else {
                    layer.msg(res.msg);
                }
            }
            ,error:function(){
                layer.closeAll('loading');
            }
            ,before:function () {
                layer.load(2);
            }
        });
    });

    //拉取viator库图片
    $('#pullViatorImgs').click(function () {
        //获取产品viator_code
        var vaitorCode = "{$goods.code}";
        if(vaitorCode==''){
            layer.msg('viator商品有误！缺少viatorCode');
            return false;
        }
        var loading = layer.load(1);
        $.post("/api/viator/pullViatorImages",{code:vaitorCode},function (res) {
            layer.closeAll();
            layer.msg(res.msg);
            if(res.code > 0){
                //添加图片
                var html = '';
                var imgs = $('#upload-thumb1').val();
                imgs = imgs.split(',');
                $.each(res.data,function (i,v) {
                    html += '<span class="uploadimgbox">' +
                        '<img class="layui-upload-img" src="'+v+'">' +
                        '<i class="layui-icon">&#x1006;</i>' +
                        '</span>';
                    imgs.push(v);
                })
                $('#seeupload1').append(html);
                $('#upload-thumb1').val(imgs.join(','));
            }else{
                return false;
            }
        },'json')
    })

    $("#seeupload1").on("click",".layui-icon",function(){
        $(this).parent().remove();
        thumb("seeupload1",1);
    });

    function thumb(obj,n){
        var thumbs="";
        $("#"+obj).find("img").each(function(){
            var url=$(this).attr("src");
            thumbs+=","+url;
        });
        $("#upload-thumb"+n).val(thumbs);
    }

</script>




<script>

    var ue0 = UE.getEditor('jieshao');
    // var jieshao2 = UE.getEditor('jieshao2');
    var yongshi = UE.getEditor('yongshi');
    var baohan = UE.getEditor('baohan');
    var buhan = UE.getEditor('buhan');
    var zhuyi = UE.getEditor('zhuyi');
    var tuigai = UE.getEditor('tuigai');


    function muban(t){
        var op=""
        op+=" <option  value=''>请选择</option>"
        $.each(t,function (i,v) {
            op+="<option value='"+v.id+"'>"+v.name+"</option>"
        })
        return op;
    }

    function team(t){
        var op="";
        op+="  <option value=\"999999\">自营</option>";
        $.each(t,function (i,v) {
            op+="<option value='"+v.id+"'>"+v.name+"</option>"
        });
        op+="  <option value=\"1000000\">其他</option>";
        return op;
    }


    layui.use(['layer', 'form','laydate','layedit'], function() {
        // var laydate = layui.laydate;
        var layer = layui.layer,
            $ = layui.jquery,
            laydate= layui.laydate,
            form = layui.form;

        function changepoi(){
            var id=$("#relation_type").val();
            var city=$("#city").val();
            var goods_classify=$("#classify").val();

            if(id==0){
                $('#list option').remove();
                form.render('select');
                return false;
            }
            $.post("{:url('findpoi')}",
                {
                    'id':id,
                    'city':city,
                    'goods_classify':goods_classify,
                },
                function (date) {

                    var data =JSON.parse(date);
                    console.log(data);
                    $('#list option').remove();
                    $('#list').append(muban(data.poi));


                    $('#team_id option').remove();
                    $('#team_id').append(team(data.team));

                    form.render('select');
                })
        }

        $(window).on('load', function() {
            form.on('radio(poitype)', function(data){
                var val= $(this).val();
                $("#relation_type").val(val);
                changepoi()
            })


            $('#queding').click(function () {
                var id= $(this).attr("data-id");
                console.log(id)

            })



            form.on('select(city)', function(data){
                var id=data.value;
                $("#city").val(id);
                changepoi()
            });

            form.on('select(classify)', function(data){
                var id=data.value;
                $("#classify").val(id);
                changepoi()
            });


            form.on('select(addg)', function(data){
                var id=data.value;
                var sid= $('input[name="relation_type"]:checked').val();
                // console.log($id)
                $.post("{:url('xiala')}",{'sid':sid,'id':id},function (date) {
                    var date=eval(date);
                    ue0.setContent('');
                    // jieshao2.setContent('');
                    yongshi.setContent('');
                    baohan.setContent('');
                    buhan.setContent('');
                    zhuyi.setContent('');
                    tuigai.setContent('');

                    if (date[0].hasOwnProperty('introduction') && date[0]['introduction']!==null){
                        ue0.setContent(date[0]['introduction']);
                    }
                    if (date[0].hasOwnProperty('price')  && date[0]['price']!==null){
                        baohan.setContent(date[0]['price']);
                    }
                    if (date[0].hasOwnProperty('priceno')  && date[0]['priceno']!==null){
                        buhan.setContent(date[0]['priceno']);
                    }
                    // if (date[0].hasOwnProperty('eng_introduce')  && date[0]['eng_introduce']!==null){
                    //     jieshao2.setContent(date[0]['eng_introduce']);//英文简介
                    // }
                    if (date[0].hasOwnProperty('introduce')  && date[0]['introduce']!==null){
                        ue0.setContent(date[0]['introduce']);
                    }

                    if (date[0].hasOwnProperty('careful')  && date[0]['careful']!==null){
                        zhuyi.setContent(date[0]['careful']);
                    }
                    if (date[0].hasOwnProperty('back')  && date[0]['back']!==null){
                        tuigai.setContent(date[0]['back']);

                    }


                });
            });


            //商品范围选择下拉添加事件
            //商品范围选择下拉添加事件
            form.on('select(addtrips)', function(data){
                var tripid=data.value;
                $("#addtrips").attr("data-id",tripid);
            });

            $("#addtrips").on("click",function () {
                var tripid= $("#addtrips").attr("data-id");
                var tripids=$("#tripids").val();
                var ids=tripids.split(",");

                if (tripid==999999){
                    tripids=999999;
                    var tripspan='<span class="layui-btn layui-btn-sm layui-btn-normal deltripspan" data-id="999999" style="margin: 5px 10px">全部<i class="layui-icon"></i></span>';
                    $("#tripnames").html(tripspan);
                }else{

                    for(var i=0 ; i < ids.length; i++){
                        if(tripid==ids[i]){
                            layer.msg("不能重复添加商品");
                            return false;
                        }
                        if(ids[i]==999999){
                            tripids=999999;
                            var tripspan='<span class="layui-btn layui-btn-sm layui-btn-normal deltripspan" data-id="999999" style="margin: 5px 10px">全部<i class="layui-icon"></i></span>';
                            $("#tripnames").html(tripspan);
                            $("#tripids").val(tripids);
                            return false;
                        }
                    }
                    var tripname="";
                    $("#trip").find("option").each(function () {
                        if($(this).val()==tripid){
                            tripname=$(this).html();
                        }
                    });

                    var tripspan='<span class="layui-btn layui-btn-sm layui-btn-normal deltripspan" data-id="'+tripid+'" style="margin: 5px 10px">'+tripname+'<i class="layui-icon"></i></span>';

                    if(!tripids){
                        tripids+=tripid;
                    }else{
                        tripids+=','+tripid;
                    }
                    $("#tripnames").append(tripspan);
                }



                $("#tripids").val(tripids);
            })

            $(document).on("click",'.deltripspan',function () {
                var dataid=$(this).attr("data-id");
                var tripids=$("#tripids").val();
                var ids=tripids.split(",");
                var newid="";
                for(var i=0 ; i < ids.length; i++){
                    if(ids[i]&&dataid!=ids[i]){
                        if(!newid){
                            newid+=ids[i];
                        }else{
                            newid+=","+ids[i];
                        }
                    }
                }
                $("#tripids").val(newid);
                $(this).remove();
            })

            form.on('submit(admin)', function(data) {
                $.ajax({
                    url:"{:url('admin/goods/addgoodsother')}",
                    data:$('#admin').serialize(),
                    type:'post',
                    async: false,
                    success:function(res) {
                        layer.msg(res.msg);
                        if(res.code == 1) {
                            setTimeout(function(){
                                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                parent.layer.close(index); //再执行关闭
                            },1500);
                        }
                    }
                });
                return false;
            });


            $('.example2').each(function () {
                new Sortable( document.getElementById("sortTags"), {
                    group: 'shared',
                    animation: 150,
                    scroll:true,
                    forceFallback: true,
                    onEnd:function (evt) {
                        var schedule_id = evt.to.id;
                        var one1=evt.item.id
                        var str = '';
                        $("#"+schedule_id).find(".list-group-item").each(function(){
                            str += ","+$(this).attr("id");
                        });
                        console.log(evt.to.id,evt.item.id,str)
                        return false;
                    }
                });
            });

            $(document).on('click','.list-group-item i',function () {
                var tagId = $(this).parent().attr('value');
                var subCates = $("input[name=subCates]").val();
                subCates = subCates.split(',');
                subCates.splice($.inArray(tagId,subCates),1);
                subCates = subCates.length > 0 ? subCates.join(',') : '';
                $("input[name=subCates]").val(subCates);
                $(this).parent().remove();
            })

            //设置标签
//            form.on('select(topCate)',function(data){
//                var value = data.value;
//                var subCates = [];
//                $.each(topCates,function (i,v) {
//                    if(v.id==value){
//                        subCates = v.subCates;return false;
//                    }
//                })
//                console.log(subCates);
//                var str = '';
//                $.each(subCates,function(i,v){
//                    str += "<option value='"+v.tag_id+"'>"+v.tag_name+"</option>";
//                });
//                $("#categorytags option:not(:first-child)").remove();
//                $("#categorytags").append(str);
//                $("#sortTags").children().remove();
//                form.render('select');
//            });
            //首页分类标签选择
            form.on('select(addCategoryTags)', function(data){
                //添加内容到拖拽框
                var tagId = data.value;
                var tagName = $(this).text();
                if(tagId=="" || tagId==undefined){return false;}
                //判断是否已存在
                var isExistId = false;
                $.each($("#sortTags .list-group-item"),function (i,v) {
                    if($(v).attr("value")==tagId){
                        isExistId = true;layer.msg('请勿重复选择');return false;
                    }
                })
                if(isExistId){return false;}
                var subCates = $("input[name=subCates]").val();
                subCates = (subCates=="" || subCates==undefined) ? [] : subCates.split(',');
                subCates.push(tagId);
                $("input[name=subCates]").val(subCates.join(","));
                $("#sortTags").append('<span class="list-group-item list-group-'+tagId+'" value="'+tagId+'" id="'+tagId+'">'+tagName+'<i class="layui-icon">&#x1006;</i></span>');
            });

        });
    });
</script>
</body>
</html>
